package base;

import java.util.Vector;
/**
 * inherits the properties of the parent class "com.company.FolderItem"
 */
public class Folder extends FolderItem {
    private Vector<FolderItem> folderItems;
    /**
     * invoke parent class constructor method and instance variable.
     */
    public Folder(String initialName) {
        super(initialName);
        folderItems = new Vector<FolderItem>();
    }
    /**
     * inherit the properties
     * get new folder items
     */
    public Vector<FolderItem> getFolderItems() {
        return folderItems;
    }
    /**
     * set new folder items
     */
    public void setFolderItems(Vector<FolderItem> newFolderItems) {
        folderItems = newFolderItems;
    }
    /**
     * add items to the folder
     */
    public void addFolderItem(FolderItem item) {
        folderItems.add(item);
    }
    /**
     * remove items in the folder
     */
    public void removeFolderItem(FolderItem item) {
        /**
         * items can be removed only when the folder is not empty
         */
        if(folderItems.isEmpty()){
            System.out.println("Folder is empty!");
            return;
        }
        folderItems.remove(item);
    }
    /**
     * get folder items' index
     */
    public FolderItem getFolderItem(int index) {
        return folderItems.get(index);
    }
    /**
     * get the number of folder items
     */
    public int getNumberOfFolderItems() {
        return folderItems.size();
    }
}
